package com.eos.control.action.customer;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.eos.business.service.SysProductBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.ProdctBrand;
import com.eos.orm.mybatis.model.SysProduct;
import com.hf.utils.PaginationBean;

public class BrandListAction extends AbstractBaseAction {
	private static final long serialVersionUID = 8576462242614107092L;
	private String brandName;
	private String dealFlag;
	private Integer pageNum;
	private Integer numPerPage;
	private Integer totalCount;
	private String productId;
	private List<SysProduct> productList;
	
	private List<ProdctBrand> brandList;
	
	public void setBrandName(String brandName) {
		this.brandName = brandName;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}

	public void setNumPerPage(Integer numPerPage) {
		this.numPerPage = numPerPage;
	}

	public String getBrandName() {
		return brandName;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public Integer getNumPerPage() {
		return numPerPage;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	public List<ProdctBrand> getBrandList() {
		return brandList;
	}

	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	public List<SysProduct> getProductList() {
		return productList;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String execute()  {
		try {
			SysProductBusinessService spbs = new SysProductBusinessService();
			if(pageNum == null || pageNum.intValue() ==0) pageNum =1;
			if(numPerPage == null || numPerPage.intValue() ==0) numPerPage = PAGE_SIZE;
			Map<String, String> map = new HashMap<String, String>();
			map.put("table_name", "product_brand");
			map.put("deal_flag", dealFlag);
			map.put("page_size", numPerPage+"");
			map.put("cur_page", pageNum+"");
			map.put("brand_name", brandName);
			map.put("product_id", productId);
			PaginationBean pageBean = spbs.getProductBrandList(map);
			totalCount = null != pageBean ? pageBean.getMaxcount() : 0;
			brandList = null != pageBean ? (List<ProdctBrand>)pageBean.getResultList() : null;
			
			SysProduct sysProduct = new SysProduct();
			sysProduct.setDealFlag(ConstantTool.DEAL_FALG_OK);
			sysProduct.setStatus(ConstantTool.STATUS_OK);
			productList = spbs.getSysProductExample(sysProduct);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
}
